from fastapi import APIRouter
from typing import Union, Optional

user = APIRouter()


# 路径参数
@user.get("/user/{id}")
async def getUserInfo(id):
    return {
        "user_id": id
    }


# 没有路径参数就是查询参数,Union联合类型,当union类型中包含none可以用optional
@user.get("/assets")
async def getAssets(kd, money: Union[str, None] = None, points: Optional[str] = None):
    return {
        "assets": kd,
        "money": money,
        "points": points
    }
